package view;

import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import net.miginfocom.swing.MigLayout;
import javax.swing.SwingConstants;

public class CuePanel extends JPanel
{
	private JLabel mscTypeLabel;
	private JTextField mscCommandLabel;
	private JLabel cueTypeLabel;
	private JTextField cueNumberLabel;
	private JTextField labelLabel;
	private JLabel targetLabel;
	private JTextField prewaitLabel;
	private JLabel lengthLabel;

	public CuePanel(String[] cueInfo, MouseListener controller)
	{
		/**
		 * Length of 7
		 * AUDIO CUES -> DISREGARD newCueInfo[3-5]
		 * newCueInfo[0] = CUE TYPE		
		 * newCueInfo[1] = LABEL
		 * newCueInfo[2] = JMIDI CUE NUMBER
		 * newCueInfo[3] = MSC TYPE
		 * newCueInfo[4] = MSC CUE NUMBER
		 * newCueInfo[5] = MSC COMMAND
		 * newCueInfo[6] = FILE PATH (for audio cues only)
		 */

//		mscTypeLabel = new JTextField(cueInfo[3]);
//		mscTypeLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
//		mscCommandLabel = new JTextField(cueInfo[5]);
//		mscCommandLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		
		this.setLayout(new MigLayout("insets , gap 0", "[50px:50px:50px,grow 25][50px:50px:50px,grow 15][grow 150][175px:175px:175px,grow 50][121.5px:121.5px:121.5px,grow 40][121.5px:121.5px:121.5px,grow 40]", "[26px:26px:26px]"));
		this.setOpaque(false);
		this.addMouseListener(controller);

		cueTypeLabel = new JLabel(cueInfo[0]);
		cueTypeLabel.setHorizontalAlignment(SwingConstants.CENTER);
		cueTypeLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(cueTypeLabel, "cell 0 0,growx,width 10,aligny center");

		cueNumberLabel = new JTextField(cueInfo[2]);
		cueNumberLabel.setHorizontalAlignment(SwingConstants.CENTER);
		cueNumberLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(cueNumberLabel, "cell 1 0,growx,width 10,aligny center");

		labelLabel = new JTextField(cueInfo[1]);
		labelLabel.setHorizontalAlignment(SwingConstants.LEFT);
		labelLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(labelLabel, "cell 2 0,growx,width 10,aligny center");

		targetLabel = new JLabel();
		targetLabel.setHorizontalAlignment(SwingConstants.LEFT);
		if(cueInfo[0].equals("MSC"))
			targetLabel = new JLabel("\"Midi Device:\" " + "Q" + cueInfo[4]);
		else if(cueInfo[0].equals("Audio"))
			targetLabel = new JLabel(cueInfo[6]);
		targetLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(targetLabel, "cell 3 0,growx,width 10,aligny center");

		prewaitLabel = new JTextField("Pre Wait");
		prewaitLabel.setHorizontalAlignment(SwingConstants.CENTER);
		prewaitLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(prewaitLabel, "cell 4 0,growx,width 10,aligny center");

		lengthLabel = new JLabel("Action Length");
		lengthLabel.setHorizontalAlignment(SwingConstants.CENTER);
		lengthLabel.setFont(new Font("Helvetica", Font.PLAIN, 16));
		this.add(lengthLabel, "cell 5 0,growx,width 10,aligny center");

		this.invalidate();
		this.validate();
		this.repaint();
	}

	protected String getMscType()
	{
		return mscTypeLabel.getText();
	}

	protected String getMscCommand()
	{
		return mscCommandLabel.getText();
	}

	protected String getCueType()
	{
		return cueTypeLabel.getText();
	}

	public String getCueNumber()
	{
		return cueNumberLabel.getText();
	}

	protected String getLabel()
	{
		return labelLabel.getText();
	}

	protected String getTarget()
	{
		return targetLabel.getText();
	}

	protected String getPrewait()
	{
		return prewaitLabel.getText();
	}

	protected String getLength()
	{
		return lengthLabel.getText();
	}
	
	protected void setMscType(String text)
	{
		 mscTypeLabel.setText(text);
	}

	protected void setMscCommand(String text)
	{
		 mscCommandLabel.setText(text);
	}

	protected void setCueType(String text)
	{
		 cueTypeLabel.setText(text);
	}

	protected void setCueNumber(String text)
	{
		 cueNumberLabel.setText(text);
	}

	protected void setLabel(String text)
	{
		 labelLabel.setText(text);
	}

	protected void setTarget(String text)
	{
		 targetLabel.setText(text);
	}

	protected void setPrewait(String text)
	{
		 prewaitLabel.setText(text);
	}

	protected void setLength(String text)
	{
		 lengthLabel.setText(text);
	}
}
